﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<META name="keywords" lang="zh" content="卫礼贤, 易经, 占卜, 八卦, 起卦, 周易">
<META name="keywords" lang="en"
	content="i ching, cast, JavaScript, yi jing, Richard Wilhelm ,iching, the Book of Changes, divination">
<title>I Ching Mouse Caster</title>
<!-- <script src='http://localhost/firebug/firebug-lite.js'></script>
 -->
<style>
* {
	cursor: crosshair;
}

a,button {
	cursor: pointer;
}
</style>
<script>
		function init(){
			document.getElementById('out').value='';
			
		    var check = function(regex){
	            return regex.test(navigator.userAgent.toLowerCase());
	        };
	        var isIE = !check(/opera/) && check(/msie/);
			if(isIE){
				document.getElementById('castId').onkeyup = function(){
					checkCastId(document.getElementById('castId'));
				};
			}
			
		}

		function checkCastId(me){
			
			//console.log(me.value);
			me.value = me.value.replace(/[^6-9]/g,'');
			if(/[6-9]{6}/.test(me.value)){
				document.getElementById("openCastIdBtn").disabled = "";
			}
			else{
				document.getElementById("openCastIdBtn").disabled = "disabled";
			}
		}
		
		function onEnterPress(event){
			//console.log(document.getElementById("openCastIdBtn").disabled);
			if(document.getElementById("openCastIdBtn").disabled){
				return;
			}
			event = window.event? window.event : event;
			//console.log(event.keyCode);
			if(event.keyCode==13){
				openFromId();
			}
		}

		function openFromId(){
			var castId = document.getElementById('castId').value;
			var tmp = castId.split('');
			hexagram = [];
			while(tmp.length>0){
				hexagram.unshift(tmp.pop()-0);
			}
			output();
		}

		function reset(){
			document.getElementById('btns').style.display='none';
			var out = document.getElementById('out');
			var readme = document.getElementById('readme');
			
			{
				//cancel select texts
				var tmpTxt = readme.value;
				readme.value = '';
				readme.value += tmpTxt;
				out.value = out.value;
			}
			
			{
				//scroll to top
				out.scrollTop = 0;	
			}
			
			out.style.overflow = 'hidden';
			readme.style.overflow = 'hidden';

			toggleUnselectableObj();
			
			hexagram = [];
			document.onmousedown = begin;
			document.onmouseup = end;
			
		}
		var getXXfrom3coins = function(c1,c2,c3){
		//c1,c2,c3 are 0 or 1
			return c1+c2+c3; //return 6,7,8,9
		};


		var mouseUpDownMethod = {

			c1_begin : 0,
			c2_begin : 0,
			c3_begin : 0,
			c1_end : 0,
			c2_end : 0,
			c3_end : 0,
			get3Coins: function(){
			//实现3个硬币接口
				return {
					c1 : 2 + Math.abs(this.c1_end-this.c1_begin)%2,
					c2 : 2 + Math.abs(this.c2_end-this.c2_begin)%2,
					c3 : 2 + Math.abs(this.c3_end-this.c3_begin)%2,
					toString : function(){
						var ret = '(' + [this.c1 ,this.c2 ,this.c3].join('+') + ')';
						switch(this.c1 + this.c2 + this.c3){
							case 6:
								ret += "   - - x  ->   ---";
								break;
							case 7:
								ret += "   ---    ->   ---";
								break;
							case 8:
								ret += "   - -    ->   - -";
								break;
							case 9:
								ret += "   --- o  ->   - -";
								break;
						}
						return ret;
					}
				}
			}
		};

		//var pseudoRandomNumberMethod = {
//			get3Coins: function(){
//				return {
//					c1:Math.floor(2*Math.random()),
//					c2:Math.floor(2*Math.random()),
//					c3:Math.floor(2*Math.random())
//				}
//			}
		//}

		var begin = function (event){
			event = window.event? window.event : event;
			mouseUpDownMethod.c1_begin = event.clientX;
			mouseUpDownMethod.c2_begin = event.clientY;
			mouseUpDownMethod.c3_begin = new Date().getTime();
		}

		var hexagram =[];

		var end = function (event){
			event = window.event? window.event : event;
			
			mouseUpDownMethod.c1_end = event.clientX;
			mouseUpDownMethod.c2_end = event.clientY;
			mouseUpDownMethod.creset3_end = new Date().getTime();
			//console.log(mouseUpDownMethod);
			var coins = mouseUpDownMethod.get3Coins();
			//console.log(coins);
			if(hexagram.length<6){
				
				hexagram.push(getXXfrom3coins(coins.c1,coins.c2,coins.c3));
				//console.log(hexagram);
				document.getElementById('out').value = hexagram.slice(-1) + '=' + coins + '\n' 
					+ document.getElementById('out').value;
			}
			
			if(hexagram.length==6){
				document.onmousedown = null;
				document.onmouseup = null;
				output();
				
				document.getElementById('btns').style.display = '';
				document.getElementById('out').style.overflow = 'auto';
				document.getElementById('readme').style.overflow = 'auto';
				toggleUnselectableObj();
			}
			
		}

		function toggleUnselectableObj(){
			var usos = document.getElementsByName('unselectableObj');
			for(var i=0;i<usos.length;i++){
				usos[i].unselectable = usos[i].unselectable=='on' ? 'off' : 'on';	//for ie
				if(usos[i].style.getPropertyValue){
					//for ff webkit
					usos[i].style.setProperty("-moz-user-select",(usos[i].style.getPropertyValue("-moz-user-select")=='none' ? '': 'none'),'');
					usos[i].style.setProperty("-webkit-user-select",(usos[i].style.getPropertyValue("-webkit-user-select")=='none' ? '': 'none'),'');
				}
			}
		}


		var Trigrams={
			"|||":{"names":{"zh":"乾","pinYin":"qián","en":"the Creative, Force"},"imageInNature":{"zh":"天","en":"heaven,aether"}},
			"||¦":{"names":{"zh":"兌","pinYin":"duì","en":"the Joyous, Open"},"imageInNature":{"zh":"澤","en":"swamp,marsh"}},
			"|¦|":{"names":{"zh":"離","pinYin":"lí","en":"the Clinging, Radiance"},"imageInNature":{"zh":"火","en":"fire"}},
			"|¦¦":{"names":{"zh":"震","pinYin":"zhèn","en":"the Arousing, Shake"},"imageInNature":{"zh":"雷","en":"thunder"}},
			"¦||":{"names":{"zh":"巽","pinYin":"xùn","en":"the Gentle, Ground"},"imageInNature":{"zh":"風","en":"wind,wood"}},
			"¦|¦":{"names":{"zh":"坎","pinYin":"kǎn","en":"the Abysmal, Gorge"},"imageInNature":{"zh":"水","en":"water"}},
			"¦¦|":{"names":{"zh":"艮","pinYin":"gèn","en":"Keeping Still, Bound"},"imageInNature":{"zh":"山","en":"mountain"}},
			"¦¦¦":{"names":{"zh":"坤","pinYin":"kūn","en":"the Receptive, Field"},"imageInNature":{"zh":"地","en":"earth"}}
		};

		var Hexagrams={
			"||||||":{"no":1,"names":{"zh":"乾","wilhelm":"The Creative","pinYin":"qián","en":"Force"},"modernInterpretations":{"en":"Possessing Creative Power & Skill","zh":"具有创造力和技巧的"}},
			"¦¦¦¦¦¦":{"no":2,"names":{"zh":"坤","wilhelm":"The Receptive","pinYin":"kūn","en":"Field"},"modernInterpretations":{"en":"Needing Knowledge & Skill; Do not force matters and go with the flow","zh":""}},
			"|¦¦¦|¦":{"no":3,"names":{"zh":"屯","wilhelm":"Difficulty at the Beginning","pinYin":"chún","en":"Sprouting"},"modernInterpretations":{"en":"Sprouting","zh":"发芽,萌发"}},
			"¦|¦¦¦|":{"no":4,"names":{"zh":"蒙","wilhelm":"Youthful Folly","pinYin":"méng","en":"Enveloping"},"modernInterpretations":{"en":"Detained, Enveloped and Inexperienced","zh":""}},
			"|||¦|¦":{"no":5,"names":{"zh":"需","wilhelm":"Waiting","pinYin":"xū","en":"Attending"},"modernInterpretations":{"en":"Uninvolvement (Wait for now), Nourishment","zh":""}},
			"¦|¦|||":{"no":6,"names":{"zh":"訟","wilhelm":"Conflict","pinYin":"sòng","en":"Arguing"},"modernInterpretations":{"en":"Engagement in Conflict","zh":""}},
			"¦|¦¦¦¦":{"no":7,"names":{"zh":"師","wilhelm":"The Army","pinYin":"shī","en":"Leading"},"modernInterpretations":{"en":"Bringing Together, Teamwork","zh":""}},
			"¦¦¦¦|¦":{"no":8,"names":{"zh":"比","wilhelm":"Holding Together","pinYin":"bǐ","en":"Grouping"},"modernInterpretations":{"en":"Union","zh":""}},
			"|||¦||":{"no":9,"names":{"zh":"小畜","wilhelm":"Small Taming","pinYin":"xiǎo chù","en":"Small Accumulating"},"modernInterpretations":{"en":"Accumulating Resources","zh":""}},
			"||¦|||":{"no":10,"names":{"zh":"履","wilhelm":"Treading (Conduct)","pinYin":"lǚ","en":"Treading"},"modernInterpretations":{"en":"Continuing with Alertness","zh":""}},
			"|||¦¦¦":{"no":11,"names":{"zh":"泰","wilhelm":"Peace","pinYin":"tài","en":"Pervading"},"modernInterpretations":{"en":"Pervading","zh":""}},
			"¦¦¦|||":{"no":12,"names":{"zh":"否","wilhelm":"Standstill","pinYin":"pǐ","en":"Obstruction"},"modernInterpretations":{"en":"Stagnation","zh":"停滞"}},
			"|¦||||":{"no":13,"names":{"zh":"同人","wilhelm":"Fellowship","pinYin":"tóng rén","en":"Concording People"},"modernInterpretations":{"en":"Fellowship, Partnership","zh":"伙伴关系,合作关系"}},
			"||||¦|":{"no":14,"names":{"zh":"大有","wilhelm":"Great Possession","pinYin":"dà yǒu","en":"Great Possessing"},"modernInterpretations":{"en":"Independence, Freedom","zh":""}},
			"¦¦|¦¦¦":{"no":15,"names":{"zh":"謙","wilhelm":"Modesty","pinYin":"qiān","en":"Humbling"},"modernInterpretations":{"en":"Being Reserved, Refraining","zh":""}},
			"¦¦¦|¦¦":{"no":16,"names":{"zh":"豫","wilhelm":"Enthusiasm","pinYin":"yù","en":"Providing-For"},"modernInterpretations":{"en":"Inducement, New Stimulus","zh":""}},
			"|¦¦||¦":{"no":17,"names":{"zh":"隨","wilhelm":"Following","pinYin":"suí","en":"Following"},"modernInterpretations":{"en":"Following","zh":""}},
			"¦||¦¦|":{"no":18,"names":{"zh":"蠱","wilhelm":"Work on the Decayed","pinYin":"gǔ","en":"Corrupting"},"modernInterpretations":{"en":"Repairing","zh":""}},
			"||¦¦¦¦":{"no":19,"names":{"zh":"臨","wilhelm":"Approach","pinYin":"lín","en":"Nearing"},"modernInterpretations":{"en":"Approaching Goal, Arriving","zh":""}},
			"¦¦¦¦||":{"no":20,"names":{"zh":"觀","wilhelm":"Contemplation","pinYin":"guān","en":"Viewing"},"modernInterpretations":{"en":"The Withholding","zh":""}},
			"|¦¦|¦|":{"no":21,"names":{"zh":"噬嗑","wilhelm":"Biting Through","pinYin":"shì kè","en":"Gnawing Bite"},"modernInterpretations":{"en":"Deciding","zh":""}},
			"|¦|¦¦|":{"no":22,"names":{"zh":"賁","wilhelm":"Grace","pinYin":"bì","en":"Adorning"},"modernInterpretations":{"en":"Embellishing","zh":""}},
			"¦¦¦¦¦|":{"no":23,"names":{"zh":"剝","wilhelm":"Splitting Apart","pinYin":"bō","en":"Stripping"},"modernInterpretations":{"en":"Stripping, Flaying","zh":""}},
			"|¦¦¦¦¦":{"no":24,"names":{"zh":"復","wilhelm":"Return","pinYin":"fù","en":"Returning"},"modernInterpretations":{"en":"Returning","zh":""}},
			"|¦¦|||":{"no":25,"names":{"zh":"無妄","wilhelm":"Innocence","pinYin":"wú wàng","en":"Without Embroiling"},"modernInterpretations":{"en":"Without Rashness","zh":""}},
			"|||¦¦|":{"no":26,"names":{"zh":"大畜","wilhelm":"Great Taming","pinYin":"dà chù","en":"Great Accumulating"},"modernInterpretations":{"en":"Accumulating Wisdom","zh":""}},
			"|¦¦¦¦|":{"no":27,"names":{"zh":"頤","wilhelm":"Mouth Corners","pinYin":"yí","en":"Swallowing"},"modernInterpretations":{"en":"Seeking Nourishment","zh":""}},
			"¦||||¦":{"no":28,"names":{"zh":"大過","wilhelm":"Great Preponderance","pinYin":"dà guò","en":"Great Exceeding"},"modernInterpretations":{"en":"Great Surpassing","zh":""}},
			"¦|¦¦|¦":{"no":29,"names":{"zh":"坎","wilhelm":"The Abysmal Water","pinYin":"kǎn","en":"Gorge"},"modernInterpretations":{"en":"Darkness, Gorge","zh":""}},
			"|¦||¦|":{"no":30,"names":{"zh":"離","wilhelm":"The Clinging","pinYin":"lí","en":"Radiance"},"modernInterpretations":{"en":"Clinging, Attachment","zh":""}},
			"¦¦|||¦":{"no":31,"names":{"zh":"咸","wilhelm":"Influence","pinYin":"xián","en":"Conjoining"},"modernInterpretations":{"en":"Attraction","zh":""}},
			"¦|||¦¦":{"no":32,"names":{"zh":"恆","wilhelm":"Duration","pinYin":"héng","en":"Persevering"},"modernInterpretations":{"en":"Perseverance","zh":""}},
			"¦¦||||":{"no":33,"names":{"zh":"遯","wilhelm":"Retreat","pinYin":"dùn","en":"Retiring"},"modernInterpretations":{"en":"Withdrawing","zh":""}},
			"||||¦¦":{"no":34,"names":{"zh":"大壯","wilhelm":"Great Power","pinYin":"dà zhuàng","en":"Great Invigorating"},"modernInterpretations":{"en":"Great Boldness","zh":""}},
			"¦¦¦|¦|":{"no":35,"names":{"zh":"晉","wilhelm":"Progress","pinYin":"jìn","en":"Prospering"},"modernInterpretations":{"en":"Expansion, Promotion","zh":""}},
			"|¦|¦¦¦":{"no":36,"names":{"zh":"明夷","wilhelm":"Darkening of the Light","pinYin":"míng yí","en":"Brightness Hiding"},"modernInterpretations":{"en":"Brilliance Injured","zh":""}},
			"|¦|¦||":{"no":37,"names":{"zh":"家人","wilhelm":"The Family","pinYin":"jiā rén","en":"Dwelling People"},"modernInterpretations":{"en":"Family","zh":""}},
			"||¦|¦|":{"no":38,"names":{"zh":"睽","wilhelm":"Opposition","pinYin":"kuí","en":"Polarising"},"modernInterpretations":{"en":"Division, Divergence","zh":""}},
			"¦¦|¦|¦":{"no":39,"names":{"zh":"蹇","wilhelm":"Obstruction","pinYin":"jiǎn","en":"Limping"},"modernInterpretations":{"en":"Halting, Hardship","zh":""}},
			"¦|¦|¦¦":{"no":40,"names":{"zh":"解","wilhelm":"Deliverance","pinYin":"xiè","en":"Taking-Apart"},"modernInterpretations":{"en":"Liberation, Solution","zh":"解放,解决"}},
			"||¦¦¦|":{"no":41,"names":{"zh":"損","wilhelm":"Decrease","pinYin":"sǔn","en":"Diminishing"},"modernInterpretations":{"en":"Decrease","zh":"减少"}},
			"|¦¦¦||":{"no":42,"names":{"zh":"益","wilhelm":"Increase","pinYin":"yì","en":"Augmenting"},"modernInterpretations":{"en":"Increase","zh":"增加"}},
			"|||||¦":{"no":43,"names":{"zh":"夬","wilhelm":"Breakthrough","pinYin":"guài","en":"Parting"},"modernInterpretations":{"en":"Separation","zh":"分离"}},
			"¦|||||":{"no":44,"names":{"zh":"姤","wilhelm":"Coming to Meet","pinYin":"gòu","en":"Coupling"},"modernInterpretations":{"en":"Encountering","zh":""}},
			"¦¦¦||¦":{"no":45,"names":{"zh":"萃","wilhelm":"Gathering Together","pinYin":"cuì","en":"Clustering"},"modernInterpretations":{"en":"Association, Companionship","zh":""}},
			"¦||¦¦¦":{"no":46,"names":{"zh":"升","wilhelm":"Pushing Upward","pinYin":"shēng","en":"Ascending"},"modernInterpretations":{"en":"Growing Upward","zh":""}},
			"¦|¦||¦":{"no":47,"names":{"zh":"困","wilhelm":"Oppression","pinYin":"kùn","en":"Confining"},"modernInterpretations":{"en":"Exhaustion","zh":""}},
			"¦||¦|¦":{"no":48,"names":{"zh":"井","wilhelm":"The Well","pinYin":"jǐng","en":"Welling"},"modernInterpretations":{"en":"Replenishing, Renewal","zh":""}},
			"|¦|||¦":{"no":49,"names":{"zh":"革","wilhelm":"Revolution","pinYin":"gé","en":"Skinning"},"modernInterpretations":{"en":"Abolishing the Old","zh":"除旧"}},
			"¦|||¦|":{"no":50,"names":{"zh":"鼎","wilhelm":"The Cauldron","pinYin":"dǐng","en":"Holding"},"modernInterpretations":{"en":"Establishing the New","zh":""}},
			"|¦¦|¦¦":{"no":51,"names":{"zh":"震","wilhelm":"Arousing","pinYin":"zhèn","en":"Shake"},"modernInterpretations":{"en":"Mobilizing","zh":""}},
			"¦¦|¦¦|":{"no":52,"names":{"zh":"艮","wilhelm":"The Keeping Still","pinYin":"gèn","en":"Bound"},"modernInterpretations":{"en":"Immobility","zh":""}},
			"¦¦|¦||":{"no":53,"names":{"zh":"漸","wilhelm":"Development","pinYin":"jiàn","en":"Infiltrating"},"modernInterpretations":{"en":"Auspicious Outlook, Infiltration","zh":""}},
			"||¦|¦¦":{"no":54,"names":{"zh":"歸妹","wilhelm":"The Marrying Maiden","pinYin":"guī mèi","en":"Converting The Maiden"},"modernInterpretations":{"en":"Marrying","zh":"婚嫁"}},
			"|¦||¦¦":{"no":55,"names":{"zh":"豐","wilhelm":"Abundance","pinYin":"fēng","en":"Abounding"},"modernInterpretations":{"en":"Goal Reached, Ambition Achieved","zh":""}},
			"¦¦||¦|":{"no":56,"names":{"zh":"旅","wilhelm":"The Wanderer","pinYin":"lǚ","en":"Sojourning"},"modernInterpretations":{"en":"Travel","zh":""}},
			"¦||¦||":{"no":57,"names":{"zh":"巽","wilhelm":"The Gentle","pinYin":"xùn","en":"Ground"},"modernInterpretations":{"en":"Subtle Influence","zh":""}},
			"||¦||¦":{"no":58,"names":{"zh":"兌","wilhelm":"The Joyous","pinYin":"duì","en":"Open"},"modernInterpretations":{"en":"Overt Influence","zh":""}},
			"¦|¦¦||":{"no":59,"names":{"zh":"渙","wilhelm":"Dispersion","pinYin":"huàn","en":"Dispersing"},"modernInterpretations":{"en":"Dispersal","zh":""}},
			"||¦¦|¦":{"no":60,"names":{"zh":"節","wilhelm":"Limitation","pinYin":"jié","en":"Articulating"},"modernInterpretations":{"en":"Discipline","zh":""}},
			"||¦¦||":{"no":61,"names":{"zh":"中孚","wilhelm":"Inner Truth","pinYin":"zhōng fú","en":"Centre Confirming"},"modernInterpretations":{"en":"Staying Focused, Avoid Misrepresentation","zh":""}},
			"¦¦||¦¦":{"no":62,"names":{"zh":"小過","wilhelm":"Small Preponderance","pinYin":"xiǎo guò","en":"Small Exceeding"},"modernInterpretations":{"en":"Small Surpassing","zh":""}},
			"|¦|¦|¦":{"no":63,"names":{"zh":"既濟","wilhelm":"After Completion","pinYin":"jì jì","en":"Already Fording"},"modernInterpretations":{"en":"Completion","zh":"完成"}},
			"¦|¦|¦|":{"no":64,"names":{"zh":"未濟","wilhelm":"Before Completion","pinYin":"wèi jì","en":"Not-Yet Fording"},"modernInterpretations":{"en":"Incompletion","zh":"未完成"}}
		}
		var getUnicode=function(no){
			
		}

		var output=function(){
			
			var show=[];
			var _show=[];
			var XOR_show=[];
			var hexagramZipped=[];	//only consider odd OR even
			var _hexagramZipped=[];
			var XOR_hexagramZipped=[];
			for(var i=0;i<6;i++){
				switch(hexagram[i]){
					case 6:
						hexagramZipped[i]="¦";
						show[i]="- -";
						_hexagramZipped[i]="|";
						_show[i]="---";
						XOR_hexagramZipped[i]="|";
						XOR_show[i]="---";
						break;
					case 7:
						hexagramZipped[i]="|";
						show[i]="---";
						_hexagramZipped[i]="|";
						_show[i]="---";
						XOR_hexagramZipped[i]="¦";
						XOR_show[i]="- -";
						break;
					case 8:
						hexagramZipped[i]="¦";
						show[i]="- -";
						_hexagramZipped[i]="¦";
						_show[i]="- -";
						XOR_hexagramZipped[i]="¦";
						XOR_show[i]="- -";
						break;
					case 9:
						hexagramZipped[i]="|";
						show[i]="---";
						_hexagramZipped[i]="¦";
						_show[i]="- -";
						XOR_hexagramZipped[i]="|";
						XOR_show[i]="---";
						break;
				}
			}

			var out = "\n\n=== " + new Date().toLocaleString()+ " ===\n\n";
			for(var k=5;k>=0;k--){
				out += show[k]+'   XOR   '+XOR_show[k]+'   =   '+_show[k]+'\n';
			}
			
			var lower = hexagramZipped[0]+hexagramZipped[1]+hexagramZipped[2];
			var _lower = _hexagramZipped[0]+_hexagramZipped[1]+_hexagramZipped[2];
			var XOR_lower = XOR_hexagramZipped[0]+XOR_hexagramZipped[1]+XOR_hexagramZipped[2];
			var upper = hexagramZipped[3]+hexagramZipped[4]+hexagramZipped[5];
			var _upper = _hexagramZipped[3]+_hexagramZipped[4]+_hexagramZipped[5];
			var XOR_upper = XOR_hexagramZipped[3]+XOR_hexagramZipped[4]+XOR_hexagramZipped[5];
			var lowerAndUpper = hexagramZipped.join("");
			var _lowerAndUpper = _hexagramZipped.join("");
			var XOR_lowerAndUpper = XOR_hexagramZipped.join("");
			
			var no = Hexagrams[lowerAndUpper].no;
			var _no = Hexagrams[_lowerAndUpper].no;
			var XOR_no = Hexagrams[XOR_lowerAndUpper].no;
			
			{
				//output 水天需(5) XOR[异或] 地水師(7) = 水火既濟(63)
				out += '\n';
				if(upper==lower){
					out += Trigrams[upper].names.zh + "为" + Trigrams[upper].imageInNature.zh;
				}
				else{
					out += Trigrams[upper].imageInNature.zh + Trigrams[lower].imageInNature.zh + Hexagrams[lowerAndUpper].names.zh;
				}
				
				out += '(' + no + ')';

				out += ' XOR[异或] ';
				if(XOR_upper==XOR_lower){
					out += Trigrams[XOR_upper].names.zh + "为" + Trigrams[XOR_upper].imageInNature.zh;
				}
				else{
					out += Trigrams[XOR_upper].imageInNature.zh + Trigrams[XOR_lower].imageInNature.zh + Hexagrams[XOR_lowerAndUpper].names.zh;
				}
				out += '(' + XOR_no + ')';

				out += ' = ';
				if(_upper==_lower){
					out += Trigrams[_upper].names.zh + "为" + Trigrams[_upper].imageInNature.zh;
				}
				else{
					out += Trigrams[_upper].imageInNature.zh + Trigrams[_lower].imageInNature.zh + Hexagrams[_lowerAndUpper].names.zh;
				}
				out += '(' + _no + ')';
				
			}

			
			{
				//generate URLs 
				var bins = lowerAndUpper.replace(/[|]/g , "1").replace(/[¦]/g , "0").split('').reverse().join('');
				var _bins = _lowerAndUpper.replace(/[|]/g , "1").replace(/[¦]/g , "0").split('').reverse().join('');
				var XOR_bins = XOR_lowerAndUpper.replace(/[|]/g , "1").replace(/[¦]/g , "0").split('').reverse().join('');

				var baseLofting = 'http://www.emotionaliching.com/myweb/lofting/x';
				var lofting = baseLofting + bins + '.html';
				var _lofting = baseLofting + _bins + '.html';
				var XOR_lofting = baseLofting + XOR_bins + '.html';

				var baseZhURL = 'http://www.64gua.com/ebook/zyj/html/jie1/';
				var zhURL = baseZhURL + bins + '.html';
				var _zhURL = baseZhURL + _bins + '.html';
				var XOR_zhURL = baseZhURL + XOR_bins + '.html';

				var baseBookOfSunMoonURL = 'http://www.yijing.nl/i_ching/hex_';
				var bookOfSunMoonURL = baseBookOfSunMoonURL + (Math.floor((no-1)/16)*16+1) + '-' + (Math.ceil(no/16)*16) + '/hex_e_' + new Number(no/100).toFixed(2).slice(-2) + '.htm';
				var _bookOfSunMoonURL = baseBookOfSunMoonURL + (Math.floor((_no-1)/16)*16+1) + '-' + (Math.ceil(_no/16)*16) + '/hex_e_' + new Number(_no/100).toFixed(2).slice(-2) + '.htm';
				var XOR_bookOfSunMoonURL = baseBookOfSunMoonURL + (Math.floor((XOR_no-1)/16)*16+1) + '-' + (Math.ceil(XOR_no/16)*16) + '/hex_e_' + new Number(XOR_no/100).toFixed(2).slice(-2) + '.htm';
				
				var baseWilhelmURL= "http://wengu.tartarie.com/wg/wengu.php?l=Yijing&lang=en";
				var wilhelmURL = baseWilhelmURL + "&no=" +  no ;
				var _wilhelmURL = baseWilhelmURL + "&no=" +  _no ;
				var XOR_wilhelmURL =  baseWilhelmURL + "&no=" +  XOR_no ;
				
				var thisTimeId = hexagram.join(''); 
				var afpcURL = baseWilhelmURL + "&no=" + no + "&tire=" + thisTimeId;
				 
			}
			
			{
				//output id and links
				out += '\n\n本次占卜ID:\n1->' + thisTimeId + '<-6';
				out += '\n\n本次占卜链接:\n' + afpcURL;
				out += '\n\n以上由i-ching-mouse-caster生成:\nhttp://code.google.com/p/i-ching-mouse-caster/\n';
			}
			
			
			{
				//generate links
				var links = document.getElementById('links');
				
				links.innerHTML = ' | <b><a target="_blank" href="' + afpcURL + '" >本次占卜</a></b>'; 

				links.innerHTML += ' | Wilhelm: <a target="_blank" href="'+wilhelmURL+'">'+ Hexagrams[lowerAndUpper].names.zh +'</a>XOR<a target="_blank" href="'+XOR_wilhelmURL+'">'+ Hexagrams[XOR_lowerAndUpper].names.zh +'</a>=<a target="_blank" href="'+_wilhelmURL+'">'+ Hexagrams[_lowerAndUpper].names.zh +'</a>';
				
				links.innerHTML += ' | SunMoon: <a target="_blank" href="'+bookOfSunMoonURL+'">'+ Hexagrams[lowerAndUpper].names.zh +'</a>XOR<a target="_blank" href="'+XOR_bookOfSunMoonURL+'">'+ Hexagrams[XOR_lowerAndUpper].names.zh +'</a>=<a target="_blank" href="'+_bookOfSunMoonURL+'">'+ Hexagrams[_lowerAndUpper].names.zh +'</a>';

				links.innerHTML += ' | 汉: <a target="_blank" href="'+zhURL+'">'+ Hexagrams[lowerAndUpper].names.zh +'</a>XOR<a target="_blank" href="'+XOR_zhURL+'">'+ Hexagrams[XOR_lowerAndUpper].names.zh +'</a>=<a target="_blank" href="'+_zhURL+'">'+ Hexagrams[_lowerAndUpper].names.zh +'</a>';

				links.innerHTML += ' | Lofting: <a target="_blank" href="'+lofting+'">'+ Hexagrams[lowerAndUpper].names.zh + '(' + no + ')</a>XOR<a target="_blank" href="'+XOR_lofting+'">'+ Hexagrams[XOR_lowerAndUpper].names.zh + '(' + XOR_no + ')</a>=<a target="_blank" href="'+_lofting+'">'+ Hexagrams[_lowerAndUpper].names.zh + '(' + _no + ')</a>';
				
			}

			document.getElementById("out").value = out + '\n\n' 
				+ document.getElementById("out").value;
			
		}

		
	</script>
</head>

<body onload='init()' unselectable="on" scroll='no'>
<table height="100%" width="100%" unselectable="on">
	<tr height='95%'>
		<td width='50%'><textarea id="out" name='unselectableObj'
			style="resize: none; overflow: auto; height: 100%; width: 100%;">
				</textarea></td>
		<td width='50%' unselectable="on"><textarea id="readme"
			name='unselectableObj'
			style="resize: none; overflow: auto; height: 100%; width: 100%;">
==易经鼠标起卦器==

===占卜步骤===
0. 点击开始占卜
1. 想一想要占卜的事(可选) 
2. 按住鼠标左键 
3. 随意晃动鼠标 
4. 松开鼠标左键,产生一爻 
5. 重复步骤1->4,直到产生一卦 

===打开占卜步骤===
0. 输入占卜ID
1. 点击打开占卜 

===说明===
* 本程序没有使用任何伪随机数生成器
* 完全根据您的随机动作起卦
* 概率与使用三枚硬币的经典方法相同

===附录===

====《六十四卦卦名次序歌（朱熹）》====
乾坤屯蒙需訟師，比小畜兮履泰否；
同人大有謙豫隨，蠱臨觀兮噬嗑賁；
剝復無妄大畜頤，大過坎離三十備。
咸恆遯兮及大壯，晉與明夷家人睽；
蹇解損益夬姤萃，升困井革鼎震繼；
艮漸歸妹豐旅巽，兌渙節兮中孚至；
小過既濟兼未濟，是為下經三十四。

====命令行一枚硬币模拟器====
var metaCast = {
    coins:[],
    cast:function(){
		this.coins.push(8-(new Date().getTime())%2);
		return this.toString();
    },
    reset:function(){
		this.coins=[];
		return 'Done!';
    },
    newGroup:function(){
		this.coins.push(',');
		return this.toString();
    },
    toString:function(){
		return this.coins.join('');	
    }
};



				</textarea></td>
	</tr>
	<tr id="btns" height='5%'>
		<td colspan='2' align="center">要打开占卜,请输入六位占卜ID(左起为初爻):
		1-&gt;<input id='castId' size="6" type="text" maxlength="6"
			oninput="checkCastId(this)" onkeypress="onEnterPress(event)"  style="ime-mode: disabled;" /><!--style="ime-mode: disabled; only for ie5+,ff3+,others don't support! http://code.google.com/p/chromium/issues/detail?id=4490-->&lt;-6
		<button id="openCastIdBtn" onclick='openFromId()' disabled="disabled">打开占卜</button>
		<br />
		<button onclick='reset()'>开始占卜</button>
		<br />
		<a href='http://code.google.com/p/i-ching-mouse-caster/'
			target='_blank'>本程序网站</a> <span id='links'></span></td>
	</tr>
</table>
</body>

</html>